local abs = math.abs

function testfunc1(a, b, start, stop, step, tolerance)
	local v = start
	while v <= stop do
		local ar = a(v)
		local br = b(v)
		if abs(ar - br) >= tolerance then
			assert(false, "Expected " .. br .. ", got " .. ar .. " at " .. v)
		end
		v = v + step
	end
end

testfunc1(fdlibm.sin, math.sin, -100*math.pi, 100*math.pi, 0.001, 0.000001)
testfunc1(fdlibm.cos, math.cos, -100*math.pi, 100*math.pi, 0.001, 0.000001)
testfunc1(fdlibm.tan, math.tan, math.pi/2 + 0.1, math.pi, 0.001, 0.000001)
testfunc1(fdlibm.exp, math.exp, 0.00001, 5.0, 0.001, 0.000001)
testfunc1(fdlibm.exp, math.exp, 5.0, 25.0, 0.001, 0.01)